import {
  GETSTORAGE
} from "../../services/storage/storage"
import {
  getUserInfo
} from "../../services/_utils/api"

Page({
  data: {
    // 轮播
    current: 1,
    autoplay: true,
    duration: 500,
    interval: 5000,
    swiperList: [{
        value: `https://image5.suning.cn/uimg/cms/img/168534352710560121.jpg`,
        ariaLabel: '图片1',
      },
      {
        value: `https://oss.suning.com/adpp/creative_kit/material/picture/20230418-3c3a3eff5dc1477d8b1021d9effbff4331bd751717eb41e1.png`,
        ariaLabel: '图片2',
      },
      {
        value: `https://oss.suning.com/adpp/creative_kit/material/picture/20230227-b9263e2663a44132b9c7253e79a0af342f4557fc9e004429.jpg`,
        ariaLabel: '图片1',
      },
    ],
    navigation: {
      type: 'dots-bar'
    },
    paginationPosition: 'right',

  },
  // 轮播
  onChange(e) {
    const {
      detail: {
        current,
        source
      },
    } = e;
    console.log(current, source);
  },
  onAutoplayChange(e) {
    this.setData({
      autoplay: e.detail.value,
    });
  },
  onIntervalChange(e) {
    this.setData({
      interval: e.detail.value,
    });
  },
  onDurationChange(e) {
    this.setData({
      duration: e.detail.value,
    });
  },
  // 获取个人 
  userInfo() {
    const userId = GETSTORAGE('userId')
    getUserInfo({
      wechatMiniprogramOpenId: '',
      userId: userId,
      wechatServiceOfficialAccountOpenId: '',
      wechatUnionId: ''
    }).then(res => {
      const {
        currentAgreementVersion,
        signedAgreementVersion,
        familyArchiveStatus
      } = res.data.data
      if (currentAgreementVersion == signedAgreementVersion) {
        return
      } else {
        wx.navigateTo({
          url: '/pages/caidan1/caidanyi',
        })
      }
    })
  },
  gohe() {
    wx.navigateTo({
      url: '/pages/filing/health-management-view/healt-hmanagement-view',
    })
  },
  godetail() {
    wx.navigateTo({
      url: '/pageOrder/shopping/shoppingdetail/shoppingdetail',
    })
  },
  // 上门服务
  goMakeHouseCalls() {
    wx.navigateTo({
      url: '/pageOrder/shopping/makeHouseCalls/makeHouseCalls',
    })
  },
  go() {
    wx.navigateTo({
      url: '/pages/filing/accomplish/accomplish',
    })
  },
  go111() {
    wx.navigateTo({
      url: '/pages/text/text',
    })
  },
  go222() {
    wx.navigateTo({
      url: '/pages/caidan1/caidanyi',
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */

  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.userInfo()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})